<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/yuwanzi.io/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/yuwanzi.io/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/yuwanzi.io/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/yuwanzi.io/images/logo.svg" color="#222">

<link rel="stylesheet" href="/yuwanzi.io/css/main.css">



<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.1/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">

<script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"suyuhuan.gitee.io","root":"/yuwanzi.io/","images":"/yuwanzi.io/images","scheme":"Muse","version":"8.2.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"Suche...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}};
  </script>
<meta name="description" content="Redis集群架构  每一个Redis节点使用PING-PONG的形式互相通信。  当半数以上的节点fail时,则整个集群失效。  客户端不需要连接集群所有节点,只要连接集群中任意一个节点即可。  Redis集群中内置了16384个哈希槽,当操作数据时,Redis会对key使用crc16算法算出一个结果,并把结果对16384取余,每个key都会对应0-16383之间的哈希槽,Redis会根据节点">
<meta property="og:type" content="article">
<meta property="og:title" content="如何搭建与维护一个Redis集群">
<meta property="og:url" content="https://suyuhuan.gitee.io/yuwanzi.io/2016/06/27/2016-06-27-redis-cluster01/index.html">
<meta property="og:site_name" content="玉丸子 | Blog">
<meta property="og:description" content="Redis集群架构  每一个Redis节点使用PING-PONG的形式互相通信。  当半数以上的节点fail时,则整个集群失效。  客户端不需要连接集群所有节点,只要连接集群中任意一个节点即可。  Redis集群中内置了16384个哈希槽,当操作数据时,Redis会对key使用crc16算法算出一个结果,并把结果对16384取余,每个key都会对应0-16383之间的哈希槽,Redis会根据节点">
<meta property="og:locale">
<meta property="og:image" content="http://ww3.sinaimg.cn/mw690/63503acbjw1f67o71v3m6j20av0640st.jpg">
<meta property="og:image" content="http://ww3.sinaimg.cn/mw690/63503acbjw1f67o70ppf9j20dr0fudhb.jpg">
<meta property="og:image" content="http://ww2.sinaimg.cn/mw690/63503acbjw1f67o717oqhj20cn0acmy4.jpg">
<meta property="og:image" content="http://ww3.sinaimg.cn/mw690/63503acbjw1f67o71g231j20cz03lta6.jpg">
<meta property="og:image" content="http://ww2.sinaimg.cn/mw690/63503acbjw1f67obgv67nj20an07gdim.jpg">
<meta property="article:published_time" content="2016-06-27T10:00:00.000Z">
<meta property="article:modified_time" content="2020-11-07T00:58:17.000Z">
<meta property="article:author" content="玉丸子">
<meta property="article:tag" content="Redis">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://ww3.sinaimg.cn/mw690/63503acbjw1f67o71v3m6j20av0640st.jpg">


<link rel="canonical" href="https://suyuhuan.gitee.io/yuwanzi.io/2016/06/27/2016-06-27-redis-cluster01/">


<script class="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh'
  };
</script>
<title>如何搭建与维护一个Redis集群 | 玉丸子 | Blog</title>
  




  <noscript>
  <style>
  body { margin-top: 2rem; }

  .use-motion .menu-item,
  .use-motion .sidebar,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header {
    visibility: visible;
  }

  .use-motion .header,
  .use-motion .site-brand-container .toggle,
  .use-motion .footer { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle,
  .use-motion .custom-logo-image {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line {
    transform: scaleX(1);
  }

  .search-pop-overlay, .sidebar-nav { display: none; }
  .sidebar-panel { display: block; }
  </style>
</noscript>

<link rel="alternate" href="/yuwanzi.io/atom.xml" title="玉丸子 | Blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Navigationsleiste an/ausschalten" role="button">
    </div>
  </div>

  <div class="site-meta">

    <a href="/yuwanzi.io/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">玉丸子 | Blog</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>







</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          Inhaltsverzeichnis
        </li>
        <li class="sidebar-nav-overview">
          Übersicht
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#Redis%E9%9B%86%E7%BE%A4%E6%9E%B6%E6%9E%84"><span class="nav-number">1.</span> <span class="nav-text">Redis集群架构</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Redis%E6%8A%95%E7%A5%A8%E6%9C%BA%E5%88%B6"><span class="nav-number">2.</span> <span class="nav-text">Redis投票机制</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%90%AD%E5%BB%BARedis%E9%9B%86%E7%BE%A4"><span class="nav-number">3.</span> <span class="nav-text">搭建Redis集群</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-%E5%AE%89%E8%A3%85Ruby%E7%8E%AF%E5%A2%83"><span class="nav-number">3.1.</span> <span class="nav-text">1.安装Ruby环境</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-%E6%90%AD%E5%BB%BARedis%E9%9B%86%E7%BE%A4"><span class="nav-number">3.2.</span> <span class="nav-text">2.搭建Redis集群</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-%E6%B7%BB%E5%8A%A0%E4%B8%BB%E8%8A%82%E7%82%B9"><span class="nav-number">3.3.</span> <span class="nav-text">3.添加主节点</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-%E6%B7%BB%E5%8A%A0%E4%BB%8E%E8%8A%82%E7%82%B9"><span class="nav-number">3.4.</span> <span class="nav-text">4.添加从节点</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-%E5%88%A0%E9%99%A4%E8%8A%82%E7%82%B9"><span class="nav-number">3.5.</span> <span class="nav-text">5.删除节点</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Jedis%E8%BF%9E%E6%8E%A5%E9%9B%86%E7%BE%A4"><span class="nav-number">4.</span> <span class="nav-text">Jedis连接集群</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">玉丸子</p>
  <div class="site-description" itemprop="description">这里是玉丸子的个人博客,与你一起发现更大的世界。</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/yuwanzi.io/archives">
          <span class="site-state-item-count">68</span>
          <span class="site-state-item-name">Artikel</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/yuwanzi.io/categories/">
        <span class="site-state-item-count">39</span>
        <span class="site-state-item-name">Kategorien</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/yuwanzi.io/tags/">
        <span class="site-state-item-count">46</span>
        <span class="site-state-item-name">schlagwörter</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh">
    <link itemprop="mainEntityOfPage" href="https://suyuhuan.gitee.io/yuwanzi.io/2016/06/27/2016-06-27-redis-cluster01/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/yuwanzi.io/images/avatar.gif">
      <meta itemprop="name" content="玉丸子">
      <meta itemprop="description" content="这里是玉丸子的个人博客,与你一起发现更大的世界。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="玉丸子 | Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          如何搭建与维护一个Redis集群
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Veröffentlicht am</span>

      <time title="Erstellt: 2016-06-27 18:00:00" itemprop="dateCreated datePublished" datetime="2016-06-27T18:00:00+08:00">2016-06-27</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">Bearbeitet am</span>
        <time title="Geändert am: 2020-11-07 08:58:17" itemprop="dateModified" datetime="2020-11-07T08:58:17+08:00">2020-11-07</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">in</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/yuwanzi.io/categories/%E5%90%8E%E7%AB%AF/" itemprop="url" rel="index"><span itemprop="name">后端</span></a>
        </span>
          . 
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/yuwanzi.io/categories/%E5%90%8E%E7%AB%AF/Database/" itemprop="url" rel="index"><span itemprop="name">Database</span></a>
        </span>
          . 
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/yuwanzi.io/categories/%E5%90%8E%E7%AB%AF/Database/Redis/" itemprop="url" rel="index"><span itemprop="name">Redis</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <p><img src="http://ww3.sinaimg.cn/mw690/63503acbjw1f67o71v3m6j20av0640st.jpg"></p>
<h3 id="Redis集群架构"><a href="#Redis集群架构" class="headerlink" title="Redis集群架构"></a>Redis集群架构</h3><p><img src="http://ww3.sinaimg.cn/mw690/63503acbjw1f67o70ppf9j20dr0fudhb.jpg"></p>
<ol>
<li><p>每一个<code>Redis</code>节点使用PING-PONG的形式互相通信。</p>
</li>
<li><p>当半数以上的节点fail时,则整个集群失效。</p>
</li>
<li><p>客户端不需要连接集群所有节点,只要连接集群中任意一个节点即可。</p>
</li>
<li><p><code>Redis</code>集群中内置了16384个哈希槽,当操作数据时,<code>Redis</code>会对key使用crc16算法算出一个结果,<br>并把结果对16384取余,每个key都会对应0-16383之间的哈希槽,<code>Redis</code>会根据节点数量平均的将<br>哈希槽映射到不同的节点上。</p>
</li>
</ol>
<h3 id="Redis投票机制"><a href="#Redis投票机制" class="headerlink" title="Redis投票机制"></a>Redis投票机制</h3><p><img src="http://ww2.sinaimg.cn/mw690/63503acbjw1f67o717oqhj20cn0acmy4.jpg"></p>
<p><code>Redis</code>集群中每一个节点都会参与投票,如果当半数以上的节点认为一个节点通信超时,则该节点fail。</p>
<p>当集群中任意节点的master(主机)挂掉,且这个节点没有slave(从机),则整个集群进入fail状态。</p>
<h3 id="搭建Redis集群"><a href="#搭建Redis集群" class="headerlink" title="搭建Redis集群"></a>搭建Redis集群</h3><h4 id="1-安装Ruby环境"><a href="#1-安装Ruby环境" class="headerlink" title="1.安装Ruby环境"></a>1.安装Ruby环境</h4><p>因为redis-trib.rb脚本依赖ruby环境,所以需要先安装ruby。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">yum install ruby </span><br><span class="line">yum install rubygems</span><br></pre></td></tr></table></figure>
<p>安装ruby和redis的接口程序</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">gem install &#x2F;usr&#x2F;local&#x2F;redis-3.0.0.gem</span><br></pre></td></tr></table></figure>
<h4 id="2-搭建Redis集群"><a href="#2-搭建Redis集群" class="headerlink" title="2.搭建Redis集群"></a>2.搭建Redis集群</h4><p>一个<code>Redis</code>集群最少需要3组主从机,即6个<code>Redis</code>。</p>
<p><img src="http://ww3.sinaimg.cn/mw690/63503acbjw1f67o71g231j20cz03lta6.jpg"></p>
<p>修改redis.conf配置文件,将集群开关开启。</p>
<p><img src="http://ww2.sinaimg.cn/mw690/63503acbjw1f67obgv67nj20an07gdim.jpg"></p>
<p>启动<code>Redis</code>实例</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">cd redis01</span><br><span class="line">.&#x2F;redis-server redis.conf</span><br><span class="line">cd ..</span><br><span class="line">cd redis02</span><br><span class="line">.&#x2F;redis-server redis.conf</span><br><span class="line">cd ..</span><br><span class="line">cd redis03</span><br><span class="line">.&#x2F;redis-server redis.conf</span><br><span class="line">cd ..</span><br><span class="line">cd redis04</span><br><span class="line">.&#x2F;redis-server redis.conf</span><br><span class="line">cd ..</span><br><span class="line">cd redis05</span><br><span class="line">.&#x2F;redis-server redis.conf</span><br><span class="line">cd ..</span><br><span class="line">cd redis06</span><br><span class="line">.&#x2F;redis-server redis.conf</span><br><span class="line">cd ..</span><br></pre></td></tr></table></figure>
<p>使用redis-trib.rb创建集群</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;redis-trib.rb create --replicas 1 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005  127.0.0.1:7006</span><br></pre></td></tr></table></figure>
<h4 id="3-添加主节点"><a href="#3-添加主节点" class="headerlink" title="3.添加主节点"></a>3.添加主节点</h4><p>如果想添加一个port为7007的<code>Redis</code>实例,可以使用以下命令。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;redis-trib.rb add-node 127.0.0.1:7007 127.0.0.1:7001</span><br></pre></td></tr></table></figure>
<p>当添加了一个主节点后,需要重新分配哈希槽。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;redis-trib.rb reshard 127.0.0.1:7001</span><br></pre></td></tr></table></figure>
<h4 id="4-添加从节点"><a href="#4-添加从节点" class="headerlink" title="4.添加从节点"></a>4.添加从节点</h4><p>添加一个port为7008的<code>Redis</code>实例做为7007的从节点。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.&#x2F;redis-trib.rb add-node --slave --master-id cad9f7413ec6842c971dbcc2c48b4ca959eb5db4  127.0.0.1:7008 127.0.0.1:7001</span><br></pre></td></tr></table></figure>
<p>命令格式: ./redis-trib.rb add-node –slave –master-id 主节点id 新加从节点的ip和端口 集群中节点的ip和端口(任意一个节点)。</p>
<p>主节点id可以在client中使用 <strong>cluster nodes</strong> 命令查询。</p>
<p>注意: 如果原来该结点在集群中的配置信息已经生成到cluster-config-file指定的配置文件中（如果cluster-config-file没有指定则默认为nodes.conf),则会报错:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[ERR] Node XXXXXX is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0</span><br></pre></td></tr></table></figure>
<p>解决方法: 删除生成的配置文件 nodes.conf,再执行./redis-trib.rb add-node命令。</p>
<h4 id="5-删除节点"><a href="#5-删除节点" class="headerlink" title="5.删除节点"></a>5.删除节点</h4><p>./redis-trib.rb del-node 要删除的节点的ip和端口 节点id<br>注意: 如果这个节点已经占有哈希槽,则无法删除,需要先将哈希槽分配出去。</p>
<h3 id="Jedis连接集群"><a href="#Jedis连接集群" class="headerlink" title="Jedis连接集群"></a>Jedis连接集群</h3><p>使用Jedis连接集群需要先创建JedisCluster对象。代码如下:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">test01</span><span class="params">()</span></span>&#123;</span><br><span class="line">	Set&lt;HostAndPort&gt; nodes = <span class="keyword">new</span> HashSet&lt;HostAndPort&gt;();</span><br><span class="line">	nodes.add(<span class="keyword">new</span> HostAndPort(<span class="string">&quot;192.168.145.134&quot;</span>, <span class="number">7001</span>));</span><br><span class="line">	nodes.add(<span class="keyword">new</span> HostAndPort(<span class="string">&quot;192.168.145.134&quot;</span>, <span class="number">7002</span>));</span><br><span class="line">	nodes.add(<span class="keyword">new</span> HostAndPort(<span class="string">&quot;192.168.145.134&quot;</span>, <span class="number">7003</span>));</span><br><span class="line">	nodes.add(<span class="keyword">new</span> HostAndPort(<span class="string">&quot;192.168.145.134&quot;</span>, <span class="number">7004</span>));</span><br><span class="line">	nodes.add(<span class="keyword">new</span> HostAndPort(<span class="string">&quot;192.168.145.134&quot;</span>, <span class="number">7005</span>));</span><br><span class="line">	nodes.add(<span class="keyword">new</span> HostAndPort(<span class="string">&quot;192.168.145.134&quot;</span>, <span class="number">7006</span>));</span><br><span class="line">	<span class="comment">// 创建JedisCluster</span></span><br><span class="line">	JedisCluster jedisCluster = <span class="keyword">new</span> JedisCluster(nodes);</span><br><span class="line">	<span class="comment">// 操作redis</span></span><br><span class="line">	String set = jedisCluster.set(<span class="string">&quot;hello&quot;</span>, <span class="string">&quot;helloWorld&quot;</span>);</span><br><span class="line">	String hello = jedisCluster.get(<span class="string">&quot;hello&quot;</span>);</span><br><span class="line">	System.out.println(set);</span><br><span class="line">	System.out.println(hello);</span><br><span class="line">	<span class="comment">// 关闭JedisCluster</span></span><br><span class="line">	jedisCluster.close();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>在Spring容器中维护:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">   &lt;bean class&#x3D;&quot;redis.clients.jedis.JedisCluster&quot;&gt;</span><br><span class="line">	&lt;constructor-arg name&#x3D;&quot;nodes&quot;&gt;</span><br><span class="line">		&lt;set&gt;</span><br><span class="line">			&lt;bean class&#x3D;&quot;redis.clients.jedis.HostAndPort&quot;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;host&quot; value&#x3D;&quot;192.168.145.134&quot;&#x2F;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;port&quot; value&#x3D;&quot;7001&quot;&#x2F;&gt;</span><br><span class="line">			&lt;&#x2F;bean&gt;</span><br><span class="line">			&lt;bean class&#x3D;&quot;redis.clients.jedis.HostAndPort&quot;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;host&quot; value&#x3D;&quot;192.168.145.134&quot;&#x2F;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;port&quot; value&#x3D;&quot;7002&quot;&#x2F;&gt;</span><br><span class="line">			&lt;&#x2F;bean&gt;</span><br><span class="line">			&lt;bean class&#x3D;&quot;redis.clients.jedis.HostAndPort&quot;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;host&quot; value&#x3D;&quot;192.168.145.134&quot;&#x2F;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;port&quot; value&#x3D;&quot;7003&quot;&#x2F;&gt;</span><br><span class="line">			&lt;&#x2F;bean&gt;</span><br><span class="line">			&lt;bean class&#x3D;&quot;redis.clients.jedis.HostAndPort&quot;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;host&quot; value&#x3D;&quot;192.168.145.134&quot;&#x2F;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;port&quot; value&#x3D;&quot;7004&quot;&#x2F;&gt;</span><br><span class="line">			&lt;&#x2F;bean&gt;</span><br><span class="line">			&lt;bean class&#x3D;&quot;redis.clients.jedis.HostAndPort&quot;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;host&quot; value&#x3D;&quot;192.168.145.134&quot;&#x2F;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;port&quot; value&#x3D;&quot;7005&quot;&#x2F;&gt;</span><br><span class="line">			&lt;&#x2F;bean&gt;</span><br><span class="line">			&lt;bean class&#x3D;&quot;redis.clients.jedis.HostAndPort&quot;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;host&quot; value&#x3D;&quot;192.168.145.134&quot;&#x2F;&gt;</span><br><span class="line">				&lt;constructor-arg name&#x3D;&quot;port&quot; value&#x3D;&quot;7006&quot;&#x2F;&gt;</span><br><span class="line">			&lt;&#x2F;bean&gt;</span><br><span class="line">		&lt;&#x2F;set&gt;</span><br><span class="line">	&lt;&#x2F;constructor-arg&gt;</span><br><span class="line">&lt;&#x2F;bean&gt;</span><br></pre></td></tr></table></figure>
    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/yuwanzi.io/tags/Redis/" rel="tag"># Redis</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/yuwanzi.io/2016/06/24/2016-06-24-nginx-initiation/" rel="prev" title="如何安装与搭建一个Nginx服务器">
                  <i class="fa fa-chevron-left"></i> 如何安装与搭建一个Nginx服务器
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/yuwanzi.io/2016/06/30/2016-06-30-solrcloud/" rel="next" title="SolrCloud初体验">
                  SolrCloud初体验 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>







<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      const commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">玉丸子</span>
</div>
  <div class="powered-by">Erstellt mit  <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a>
  </div>

    </div>
  </footer>

  
  <script src="//cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<script src="/yuwanzi.io/js/utils.js"></script><script src="/yuwanzi.io/js/motion.js"></script><script src="/yuwanzi.io/js/schemes/muse.js"></script><script src="/yuwanzi.io/js/next-boot.js"></script>

  






  





</body>
</html>
